

var sortedArrayToBST = function(nums) {
  if(!nums.length) return null 
  let midIndex = Math.floor(nums.length/2)
  // 实例化节点头部
  let Head = new TreeNode(nums[midIndex])
  let left = midIndex - 1
  let right = midIndex + 1
  if(left >= 0) {
    Head.left = sortedArrayToBST(nums.slice(0,midIndex))
  }
  if(right < nums.length) {
    Head.right = sortedArrayToBST(nums.slice(right))
  }
  return Head
};
for (let i = 1; i < size; i++) {
  const prev = list[i - 1], curr = list[i];
  prev.left = null;
  prev.right = curr;
}
